#include "normalwidget.h"
#include "ui_normalwidget.h"
#include "../CheckInfor/hardinfor.h"
#include "../CheckInfor/normalinfor.h"
#include "../CheckInfor/securityinfor.h"
#include <QHeaderView>
#include <QSizePolicy>
#include <QDateTime>
#include <QMessageBox>
#include "../CheckTool/reslution.h"
#define MODELPATHS "../conf/default/normal.conf"
#include<QToolTip>
#include<iostream>

QVector<QPair<Yzty::MODECODE,Yzty::ITEMCODE>> NormalWidget::ShowTools;
QVector<QSet<int>> NormalWidget::ToolMapItem;

QString BrowserV=Yzty::Reslution::GetFromString("browser --version")[0];

NormalWidget::NormalWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NormalWidget)
{
    ui->setupUi(this);
    Init_Ui();


    //需要展示的功能列表
    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::OsAndHost)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Normal),int(Yzty::NormalToolCode::HostInfor)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::HardDisk)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::Memory)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::GraphCard)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::NetCard)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::SoundCard)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::User)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::Battery)));



    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::Mouse)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::HardDisk)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::BlueTooth)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::KeyBoard)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroHistory)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroCollect)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroCookies)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::UserLogin)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Email),int(Yzty::EmailToolCode::ResEmail)));

    ShowTools.push_back((QPair<int,int>(int(Yzty::ToolCode::Hard),int(Yzty::HardToolCode::Mouse))));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Normal),int(Yzty::NormalToolCode::SoftLists)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Normal),int(Yzty::NormalToolCode::MirrorFile)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Normal),int(Yzty::NormalToolCode::PhonePlug)));

    ShowTools.push_back(QPair<int,int>(int(Yzty::ToolCode::Normal),int(Yzty::NormalToolCode::HardPart)));



    ToolMapItem[0].insert(int(Yzty::ToolCode::Normal)*Yzty::ToolMapItemHashCode+int(Yzty::NormalToolCode::HostInfor));
    ToolMapItem[1].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::HardDisk));
    ToolMapItem[2].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::Memory));
    ToolMapItem[3].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::User));
    ToolMapItem[4].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::GraphCard));
    ToolMapItem[5].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::NetCard));
    ToolMapItem[6].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::SoundCard));
    ToolMapItem[7].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::User));


    ToolMapItem[8].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::OsAndHost));
    ToolMapItem[9].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::Mouse));
    ToolMapItem[10].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::BlueTooth));
    ToolMapItem[11].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::KeyBoard));


    ToolMapItem[12].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::BroHistory));
    ToolMapItem[13].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::BroCollect));
    ToolMapItem[14].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::BroCookies));
    ToolMapItem[15].insert(int(Yzty::ToolCode::Hard)*Yzty::ToolMapItemHashCode+int(Yzty::HardToolCode::OsAndHost));
    ToolMapItem[16].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::UserLogin));
    ToolMapItem[17].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::BroCollect));


    ToolMapItem[18].insert(int(Yzty::ToolCode::Normal)*Yzty::ToolMapItemHashCode+int(Yzty::NormalToolCode::SoftLists));
    ToolMapItem[19].insert(int(Yzty::ToolCode::Normal)*Yzty::ToolMapItemHashCode+int(Yzty::NormalToolCode::MirrorFile));
}

NormalWidget::~NormalWidget()
{
    delete ui;
}

void NormalWidget::SetCurWidget(int i){
    ui->stackedWidget->setCurrentIndex(i);
    UpdateData(i);
}

void NormalWidget::Init_Ui(){
    QTextStream& fstream=Yzty::GetTextSteam(MODELPATHS);
    QStringList items=fstream.readAll().split('#');
    items.removeFirst();
    auto&& pstruct=Yzty::ConfigParse_Struct(items);
    Init_Config(pstruct);
    _plains[0][0]->setVisible(false);//隐藏主机信息的文本编辑框
}

void NormalWidget::Init_Config(QMap<int,QVector<QPair<QString,QStringList>>>& pstruct){

    int n=pstruct.size();
    ToolMapItem.resize(n);

    _models=QVector<QVector<QStandardItemModel*>>(n);
    _views=QVector<QVector<QTableView*>>(n);
    _plains=QVector<QVector<QPlainTextEdit*>>(n);
    _model_labels=QVector<QVector<QStringList>>(n);

    for(int i=0;i<n;i++){

        QWidget* w=new QWidget(this);
        ui->stackedWidget->addWidget(w);
        QGridLayout* layout=new QGridLayout(w);
        QTabWidget* tabw=new QTabWidget(this);



        for(auto& temp:pstruct[i]){
            QWidget* tw=new QWidget(tabw);
            QStandardItemModel* model=new QStandardItemModel(tw);
            QTableView*         view =new QTableView(tw);
            view->setMouseTracking(true);
            connect(view, &QTableView::entered, this, &NormalWidget::doMouseTrackTip);

            QPlainTextEdit*     edit =new QPlainTextEdit(tw);

            if(i==0)
                edit->hide();

//            QSizePolicy policy;
            view->setMinimumHeight(100);
            view->setAutoScroll(true);
//            view->setMaximumHeight(200);
            edit->setMinimumHeight(100);

            QVBoxLayout* layout=new QVBoxLayout(tw);
            layout->addWidget(view);
            layout->addSpacing(10);
            layout->addWidget(edit);

            view->setModel(model);
            _models[i].push_back(model);
            _views[i].push_back(view);
            _plains[i].push_back(edit);

            view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
            view->setEditTriggers(QAbstractItemView::NoEditTriggers);
            view->setSortingEnabled(true);
            model->setHorizontalHeaderLabels(temp.second);
            _model_labels[i].push_back(temp.second);

            tw->setLayout(layout);
            tabw->addTab(tw,temp.first);
        }

        layout->addWidget(tabw);
        w->setLayout(layout);
    }
}

void NormalWidget::UpdateData(Yzty::MODECODE code,Yzty::ITEMCODE tcode){

    ClearModel(code,tcode);

    switch (code) {
        case 0:
            UpdateHostInfor(code,tcode);
            break;
        case 1:
            UpdateDiskInfor(code,tcode);
            break;
        case 2:
            UpdateOsInfor(code,tcode);
            break;
        case 3:
            UpdateUserVerifyInfor(code,tcode);
            break;
        case 4:
            UpdateScreenProInfor(code,tcode);
            break;
        case 5:
            UpdateWirelessInfor(code,tcode);
            break;
        case 6:
            UpdateSoundCardInfor(code,tcode);
            break;
        case 7:
            UpdateOpClCardInfor(code,tcode);
            break;
        case 8:
            UpdatePhoneLinkInfor(code,tcode);
            break;
        case 9:
            UpdateMemoryInfor(code,tcode);
            break;
        case 10:
            UpdateBuleTeeth(code,tcode);
            break;
        case 11:
            UpdateOtherUsb(code,tcode);
            break;
        case 12:
            UpdateWebHistory(code,tcode);
            break;
        case 13:
            UpdateSoftNetHistory(code,tcode);
            break;
        case 14:
            UpdateCookies(code,tcode);
            break;
        case 15:
            UpdateEmail(code,tcode);
            break;
        case 16:
            UpdateNetLogin(code,tcode);
            break;
        case 17:
            UpdateWebCollect(code,tcode);
            break;
        case 18:
            UpdateSystemSoft(code,tcode);
            break;
        case 19:
            UpdateMirrorSoft(code,tcode);
            break;
        default:
            break;
    }
    return;
}

void NormalWidget::ClearModel(Yzty::MODECODE code, Yzty::ITEMCODE tcode){
    if(_models[code][tcode])
        _models[code][tcode]->clear();
    if(_plains[code][tcode])
        _plains[code][tcode]->clear();
    _models[code][tcode]->setHorizontalHeaderLabels(_model_labels[code][tcode]);
}

void NormalWidget::UpdateHostInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> tem_infor=NormalInfor::GetInstance()->GetItemInfor(int(Yzty::NormalToolCode::HostInfor));
    const Yzty::HostInfor *allinfor = dynamic_cast<const Yzty::HostInfor*>(tem_infor.first());
    const Yzty::ComputerInfo *computer_infors=allinfor->computerinfor;
    const QVector<Yzty::MemoryInfor*> memory_infors=allinfor->memoryinfors;
    const QVector<Yzty::NetInfor*> net_infors=allinfor->netinfors;
    _models[code][tcode]->appendRow(new QStandardItem("计算机信息"));
        for(int i=0;i<computer_infors->Nums;i++) {
            QList<QStandardItem*> items;
            items.push_back(new QStandardItem(computer_infors->KeyWords[i]));
            items.push_back(new QStandardItem(computer_infors->_infors[i].Information));
            items.push_back(new QStandardItem(computer_infors->_infors[i].Serialnum));
            items.push_back(new QStandardItem(computer_infors->_infors[i].CheckTip));
            items.first()->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); //设置对齐方式
            _models[code][tcode]->appendRow(items);
        }
    _models[code][tcode]->appendRow(new QStandardItem("内存信息"));
    for(const Yzty::MemoryInfor* infor:memory_infors) {
        for(int i=0;i<infor->Nums;i++) {
            QList<QStandardItem*> items;
            items.push_back(new QStandardItem(infor->KeyWords[i]));
            items.push_back(new QStandardItem(infor->_infors[i].Information));
            items.push_back(new QStandardItem(infor->_infors[i].Serialnum));
            items.push_back(new QStandardItem(infor->_infors[i].CheckTip));
            items.first()->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
            _models[code][tcode]->appendRow(items);
        }
        _models[code][tcode]->appendRow(new QStandardItem(" "));
    }
    _models[code][tcode]->appendRow(new QStandardItem("网络信息"));
    for(const Yzty::NetInfor* infor:net_infors) {
        for(int i=0;i<infor->Nums;i++) {
            QList<QStandardItem*> items;
            items.push_back(new QStandardItem(infor->KeyWords[i]));
            items.push_back(new QStandardItem(infor->_infors[i].Information));
            items.push_back(new QStandardItem(infor->_infors[i].Serialnum));
            items.push_back(new QStandardItem(infor->_infors[i].CheckTip));
            items.first()->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
            _models[code][tcode]->appendRow(items);
        }
        _models[code][tcode]->appendRow(new QStandardItem(" "));
    }
}

void NormalWidget::UpdateDiskInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
//    const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::Memory);
const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::HardDisk);
for(const Yzty::BaceInfor* temp:infors){
 //       const Yzty::memoryInfor* infor=dynamic_cast<const Yzty::memoryInfor*>(temp);
 const Yzty::diskInfor* infor=dynamic_cast<const Yzty::diskInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_prodname));    //机器名称
        items.push_back(new QStandardItem(infor->_interface));      //
        items.push_back(new QStandardItem(infor->_vendorname));         //
        items.push_back(new QStandardItem(infor->_medium));      //
        items.push_back(new QStandardItem(infor->_mgb));       //处理器信息
        items.push_back(new QStandardItem(infor->_serialnum));           //序列号
        items.push_back(new QStandardItem(infor->_interface));
        items.push_back(new QStandardItem(infor->_driver));

        for(int i=0;i<Yzty::diskInfor::keywords.size();++i)
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::diskInfor::keywords[i])
                                        +infors[0]->GetItem(i)+"</pre>");

        this->_plains[code][tcode]->appendHtml("</hr>");

        _models[code][tcode]->appendRow(items);
    }

const QVector<Yzty::BaceInfor*> infors1=NormalInfor::GetInstance()->GetItemInfor(int(Yzty::NormalToolCode::HardPart));
for(const Yzty::BaceInfor* temp:infors1){
    const Yzty::HardPartInfor* infor=dynamic_cast<const Yzty::HardPartInfor*>(temp);

    QList<QStandardItem*> items;
//
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Partittion]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Type]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::FileSystem]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::IsEncrypt]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Total]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Used]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Usable]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Check]));
    items.push_back(new QStandardItem(infor->_infors[Yzty::HardPartInfor::Decision]));

    _models[code][1]->appendRow(items);
}

}

void NormalWidget::UpdateOsInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::OsAndHost);

    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::osInfor* infor=dynamic_cast<const Yzty::osInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_osname));    //机器名称
        items.push_back(new QStandardItem(infor->_osversion));         //制造商名称
        items.push_back(new QStandardItem(infor->_kerneltype));         //系统名称
        items.push_back(new QStandardItem(infor->_kernelversion));  //内核版本

        _models[code][tcode]->appendRow(items);
    }
     for(int i=0;i<Yzty::osInfor::keywords.size();++i)
        this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::osInfor::keywords[i])
                                               +infors[0]->GetItem(i)+"</pre>");
    this->_plains[code][tcode]->appendHtml("</hr>");
}

void NormalWidget::UpdateUserVerifyInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){

    const std::vector<Yzty::BaceInfor*>& infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::User);
    for(size_t i=0;i<infors.size();++i)
    {
        QList<QStandardItem*> items;
        for(int j=0;j<Yzty::userInfor::keywords.size();++j)
            items.push_back(new QStandardItem(infors[i]->GetItem(j)));
        _models[code][tcode]->appendRow(items);

        _plains[code][tcode]->appendHtml(QString("<p><b>用户%1开关机记录</b></p>").arg(infors[i]->GetItem(0)));
        int j=1;
        for(auto& temp:dynamic_cast<Yzty::userInfor*>(infors[i])->_log)
        {
            _plains[code][tcode]->appendHtml(QString("<pre><b>%1&#9;&#9;</b>").arg(j)+temp+"</pre>");
            j++;
        }
        _plains[code][tcode]->appendHtml("</hr>");

    }

}

void NormalWidget::UpdateScreenProInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::GraphCard);
    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::graphcardInfor* infor=dynamic_cast<const Yzty::graphcardInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_prodname));    //机器名称
        items.push_back(new QStandardItem(infor->_vendorname));      //制造商名称
        items.push_back(new QStandardItem(infor->_model));         //系统名称
        items.push_back(new QStandardItem(infor->_minslt));
        items.push_back(new QStandardItem(infor->_maxslt));


        for(int i=0;i<Yzty::graphcardInfor::keywords.size();++i)
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::graphcardInfor::keywords[i])
                                        +infors[0]->GetItem(i)+"</pre>");

        this->_plains[code][tcode]->appendHtml("</hr>");

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateWirelessInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::NetCard);
    for(Yzty::BaceInfor* temp:infors){
        Yzty::networkcardInfor* infor=dynamic_cast<Yzty::networkcardInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_vendorbname));    //机器名称
        items.push_back(new QStandardItem(infor->_prodname));      //制造商名称
        items.push_back(new QStandardItem(infor->_ability));         //系统名称
        items.push_back(new QStandardItem(""));
        items.push_back(new QStandardItem(""));

        this->_plains[code][tcode]->appendHtml(QString("<b>%1</b>").arg(infor->GetItem(0)));
        for(int j=0;j<Yzty::networkcardInfor::keywords.size();++j)
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::networkcardInfor::keywords[j])
                                        +infor->GetItem(int(j))+"</pre>");

        this->_plains[code][tcode]->appendHtml("</br></br>");


        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateSoundCardInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::SoundCard);
    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::soundcardInfor* infor=dynamic_cast<const Yzty::soundcardInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_model));    //机器名称
        items.push_back(new QStandardItem(infor->_vendorname));      //制造商名称
        items.push_back(new QStandardItem(infor->_probname));         //系统名称
        items.push_back(new QStandardItem(infor->_ability));
        items.push_back(new QStandardItem(""));
        items.push_back(new QStandardItem(""));

        for(int i=0;i<Yzty::soundcardInfor::keywords.size();++i)
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::soundcardInfor::keywords[i])
                                        +infors[0]->GetItem(i)+"</pre>");

        this->_plains[code][tcode]->appendHtml("</hr>");

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateOpClCardInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::User);
    for(Yzty::BaceInfor* temp:infors){
        Yzty::userInfor* infor=dynamic_cast<Yzty::userInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_username));    //机器名称
        items.push_back(new QStandardItem(infor->_tty));      //制造商名称
        items.push_back(new QStandardItem(infor->_logtime));         //系统名称
        items.push_back(new QStandardItem(infor->_pcpu));
        items.push_back(new QStandardItem(infor->_what));

        this->_plains[code][tcode]->appendHtml(QString("<p><b>用户%1开关机记录</b></p>").arg(infor->GetItem(0)));
        int j=1;
        for(auto& temp:dynamic_cast<Yzty::userInfor*>(infor)->_log)
        {
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1&#9;&#9;</b>").arg(j)+temp+"</pre>");
            j++;
        }
        this->_plains[code][tcode]->appendHtml("</hr>");

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdatePhoneLinkInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=NormalInfor::GetInstance()->GetItemInfor(int(Yzty::NormalToolCode::PhonePlug));
        std::cout << infors.size() << std::endl;
    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::PhonePlugInfor* infor=dynamic_cast<const Yzty::PhonePlugInfor*>(temp);

        QList<QStandardItem*> items;
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::Manufacturer]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::Product]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::SerialNumber]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::idVendor]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::idProduct]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::FirstTime]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::LastTime]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::DeciceType]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::DeviceAttech]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::Check]));
        items.push_back(new QStandardItem(infor->_infors[Yzty::PhonePlugInfor::decision]));

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateMemoryInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::Memory);
    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::memoryInfor* infor=dynamic_cast<const Yzty::memoryInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_prodname));    //机器名称
        items.push_back(new QStandardItem(infor->_vendorname));         //系统名称
        items.push_back(new QStandardItem(infor->_model));      //制造商名称(
        items.push_back(new QStandardItem(infor->_slottype));      //内核版本
        items.push_back(new QStandardItem(infor->_serialnum));           //序列号
        items.push_back(new QStandardItem(infor->_speed));
        items.push_back(new QStandardItem(infor->_mhz));
        items.push_back(new QStandardItem(infor->_mgb));       //处理器信息
        items.push_back(new QStandardItem(infor->_dataw));

        for(int i=0;i<Yzty::memoryInfor::keywords.size();++i)
            this->_plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::memoryInfor::keywords[i])
                                        +infors[0]->GetItem(i)+"</pre>");

        this->_plains[code][tcode]->appendHtml("</hr>");

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateBuleTeeth(Yzty::MODECODE code,Yzty::ITEMCODE tcode){

    std::vector<Yzty::BaceInfor*> infors=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::BlueTooth);
    for(Yzty::BaceInfor* temp:infors){
        Yzty::bluetoothInfor* infor=dynamic_cast<Yzty::bluetoothInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_vendorname));    //机器名称
        items.push_back(new QStandardItem(infor->_prodname));      //制造商名称
        items.push_back(new QStandardItem("无"));                //序列号
        items.push_back(new QStandardItem(infor->_vendorname));      //内核版本
        items.push_back(new QStandardItem(infor->_prodname));       //处理器信息
        items.push_back(new QStandardItem("无详细记录"));           //序列号
        items.push_back(new QStandardItem(QDateTime::currentDateTime().toString()));
        items.push_back(new QStandardItem(infor->_hwclass));
        items.push_back(new QStandardItem(infor->_interface));
        items.push_back(new QStandardItem("待鉴定"));

        _plains[code][tcode]->appendHtml(QString("<b>蓝牙</b>"));
        for(int j=0;j<Yzty::bluetoothInfor::keywords.size();++j)
            _plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::bluetoothInfor::keywords[j])
                                        +infor->GetItem(int(j))+"</pre>");

        _plains[code][tcode]->appendHtml("</br></br>");

        _models[code][tcode]->appendRow(items);
    }

}

void NormalWidget::UpdateOtherUsb(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    std::vector<Yzty::BaceInfor*> infors_keyboard=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::KeyBoard);
    std::vector<Yzty::BaceInfor*> infors_mouse=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::Mouse);
    std::vector<Yzty::BaceInfor*> infors_battery=HardInfor::GetInstance()->GetNormalCheck(Yzty::HardToolCode::Battery);

    //keyboard
    for(Yzty::BaceInfor* temp:infors_keyboard){
        Yzty::keyboardInfor* infor=dynamic_cast<Yzty::keyboardInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_vendorname));    //机器名称
        items.push_back(new QStandardItem(infor->_probname));      //制造商名称
        items.push_back(new QStandardItem("无"));                //序列号
        items.push_back(new QStandardItem(infor->_vendorname));      //内核版本
        items.push_back(new QStandardItem(infor->_probname));       //处理器信息
        items.push_back(new QStandardItem("无详细记录"));           //序列号
        items.push_back(new QStandardItem(QDateTime::currentDateTime().toString()));
        items.push_back(new QStandardItem(infor->_hwclass));
        items.push_back(new QStandardItem(infor->_interface));
        items.push_back(new QStandardItem("待鉴定"));

        _plains[code][tcode]->appendHtml(QString("<b>键盘</b>"));
        _plains[code][tcode]->appendHtml(QString("<b>%1</b>").arg(infor->GetItem(0)));
        for(int j=0;j<Yzty::keyboardInfor::keywords.size();++j)
            _plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::keyboardInfor::keywords[j])
                                        +infor->GetItem(int(j))+"</pre>");
        _plains[code][tcode]->appendHtml("</br></br>");

        _models[code][tcode]->appendRow(items);
    }

    //mouse
    for(Yzty::BaceInfor* temp:infors_mouse){
        Yzty::mouseInfor* infor=dynamic_cast<Yzty::mouseInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_vendorname));    //机器名称
        items.push_back(new QStandardItem(infor->_probname));      //制造商名称
        items.push_back(new QStandardItem("无"));                //序列号
        items.push_back(new QStandardItem(infor->_vendorname));      //内核版本
        items.push_back(new QStandardItem(infor->_probname));       //处理器信息
        items.push_back(new QStandardItem("无详细记录"));           //序列号
        items.push_back(new QStandardItem(QDateTime::currentDateTime().toString()));
        items.push_back(new QStandardItem(infor->_hwclass));
        items.push_back(new QStandardItem(infor->_interface));
        items.push_back(new QStandardItem("待鉴定"));

        _plains[code][tcode]->appendHtml(QString("<b>鼠标</b>"));
        _plains[code][tcode]->appendHtml(QString("<b>%1</b>").arg(infor->GetItem(0)));
        for(int j=0;j<Yzty::mouseInfor::keywords.size();++j)
            _plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::mouseInfor::keywords[j])
                                        +infor->GetItem(int(j))+"</pre>");
        _plains[code][tcode]->appendHtml("</br></br>");

        _models[code][tcode]->appendRow(items);
    }

    //Battery
    for(Yzty::BaceInfor* temp:infors_battery){
        Yzty::batteryInfor* infor=dynamic_cast<Yzty::batteryInfor*>(temp);
        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_vendorname));    //机器名称
        items.push_back(new QStandardItem(infor->_probname));      //制造商名称
        items.push_back(new QStandardItem(infor->_serialnum));                //序列号
        items.push_back(new QStandardItem(infor->_vendorname));      //内核版本
        items.push_back(new QStandardItem(infor->_probname));       //处理器信息
        items.push_back(new QStandardItem("无详细记录"));           //序列号
        items.push_back(new QStandardItem(infor->_updatedtime));
        items.push_back(new QStandardItem("电池"));
        items.push_back(new QStandardItem("usb"));
        items.push_back(new QStandardItem("待鉴定"));

        _plains[code][tcode]->appendHtml(QString("<b>电池</b>"));
        _plains[code][tcode]->appendHtml(QString("<b>%1</b>").arg(infor->GetItem(0)));
        for(int j=0;j<Yzty::batteryInfor::keywords.size();++j)
            _plains[code][tcode]->appendHtml(QString("<pre><b>%1:&#9;&#9;&#9;</b>").arg(Yzty::batteryInfor::keywords[j])
                                        +infor->GetItem(int(j))+"</pre>");
        _plains[code][tcode]->appendHtml("</br></br>");

        _models[code][tcode]->appendRow(items);
    }


}

void NormalWidget::UpdateWebHistory(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::BroHistory));

    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::WebHistoryInfor* infor=dynamic_cast<const Yzty::WebHistoryInfor*>(temp);

        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebHistoryInfor::TITLE]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebHistoryInfor::URL]));

        QString time=QDateTime::fromSecsSinceEpoch(infor->_infors[Yzty::WebHistoryInfor::LOGTIME].toLongLong()/1000000  - 11644473600).toString("yyyy-MM-dd hh:mm:ss");

        items.push_back(new QStandardItem(time));

        items.push_back(new QStandardItem("Browser"));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebHistoryInfor::USER]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebHistoryInfor::LOGNMS]));

        _models[code][tcode]->appendRow(items);
    }

}

void NormalWidget::UpdateSoftNetHistory(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    ClearModel(code,tcode);

}

void NormalWidget::UpdateCookies(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::BroCookies));
    if(infors.size()==0)
        _plains[code][tcode]->appendHtml("由于路径不可访问,或者加密Cookies拒绝访问");
    else{
      for(const Yzty::BaceInfor* temp:infors){
        const Yzty::WebCookiesInfor* infor=dynamic_cast<const Yzty::WebCookiesInfor*>(temp);

        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCookiesInfor::NAME]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebHistoryInfor::URL]));

        QString time=QDateTime::fromSecsSinceEpoch(infor->_infors[Yzty::WebCookiesInfor::TIME].toLongLong()/1000000  - 11644473600).toString("yyyy-MM-dd hh:mm:ss");

        items.push_back(new QStandardItem(time));

        items.push_back(new QStandardItem("Browser"));     //浏览器名称

        items.push_back(new QStandardItem(BrowserV));     //版本

        items.push_back(new QStandardItem("Chrom"));     //内核

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCookiesInfor::USER]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCookiesInfor::PATH]));

        _models[code][tcode]->appendRow(items);
      }
    }
}

void NormalWidget::UpdateEmail(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    ClearModel(code,tcode);
    static int flag=1;
    if(flag){
        flag=QMessageBox::warning(this,"拒绝访问","由于未明确提供邮箱服务器地址，暂无解析",QMessageBox::Ok|QMessageBox::Cancel);

    }
}

void NormalWidget::UpdateNetLogin(Yzty::MODECODE code,Yzty::ITEMCODE tcode){

    const QVector<Yzty::BaceInfor*>& _infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::UserLogin));
    for(const Yzty::BaceInfor* temp:_infors){
        const Yzty::UserLoginInfor* infor=dynamic_cast<const Yzty::UserLoginInfor*>(temp);
        QList<QStandardItem*> items;
        for(const QString& content:infor->_infors){
            QStandardItem* t=new QStandardItem(content);
            items.push_back(t);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateWebCollect(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::BroCollect));

    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::WebCollect* infor=dynamic_cast<const Yzty::WebCollect*>(temp);

        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCollect::URL]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCollect::TITLE]));

        QString time=QDateTime::fromSecsSinceEpoch(infor->_infors[Yzty::WebCookiesInfor::TIME].toLongLong()/1000000  - 11644473600).toString("yyyy-MM-dd hh:mm:ss");

        items.push_back(new QStandardItem("暂无记录"));

        items.push_back(new QStandardItem("Browser"));     //浏览器名称

        items.push_back(new QStandardItem(BrowserV));     //版本

        items.push_back(new QStandardItem("Chrom"));     //内核

        items.push_back(new QStandardItem(infor->_infors[Yzty::WebCollect::USER]));

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateSystemSoft(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=NormalInfor::GetInstance()->GetItemInfor(int(Yzty::NormalToolCode::SoftLists));

    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::SystemSoftList* infor=dynamic_cast<const Yzty::SystemSoftList*>(temp);

        QList<QStandardItem*> items;

        items.push_back(new QStandardItem(infor->_infors[Yzty::SystemSoftList::Name]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::SystemSoftList::Version]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::SystemSoftList::Struct]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::SystemSoftList::Time]));

        items.push_back(new QStandardItem(">=10MB"));

        items.push_back(new QStandardItem(infor->_descripe));

        items.push_back(new QStandardItem("待鉴定"));

        _models[code][tcode]->appendRow(items);
    }
}

void NormalWidget::UpdateMirrorSoft(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*> infors=NormalInfor::GetInstance()->GetItemInfor(int(Yzty::NormalToolCode::MirrorFile));

    for(const Yzty::BaceInfor* temp:infors){
        const Yzty::MirrorFile* infor=dynamic_cast<const Yzty::MirrorFile*>(temp);

        QList<QStandardItem*> items;
//文件名称 文件类型 文件路径 大小
        items.push_back(new QStandardItem(infor->_infors[Yzty::MirrorFile::Name]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::MirrorFile::Type]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::MirrorFile::Path]));

        items.push_back(new QStandardItem(infor->_infors[Yzty::MirrorFile::Size]));

        _models[code][tcode]->appendRow(items);
    }
}
void NormalWidget::doMouseTrackTip(QModelIndex index)
{
    QToolTip::showText(QCursor::pos(), index.data().toString());
}
